#!/bin/bash
#========================================================================
# Author: YSLin
# Email: 
# File Name: trap.sh
# Description: 
#   1.處理signals呼叫name函式
#     trap name signals
#   2.忽略signals
#     trap '' signals
#     trap : signals
#   3.恢復被忽略的signals
#     trap signals

# Here name is a list of commands or the name of a shell function to execute when a signal in the list of
# specified signals is received. If name is not given, trap resets the action for the given signals to be the
# default action.

# Ctrl-C (in older Unices, DEL) sends an INT signal (SIGINT); by default, this causes the process to terminate.
# Ctrl-Z sends a TSTP signal (SIGTSTP); by default, this causes the process to suspend execution.
# Ctrl-\ sends a QUIT signal (SIGQUIT); by default, this causes the process to terminate and dump core.

# Edit History: 
#   2011-01-20    File created.
#========================================================================
#enter ctrl+\ to show this message
Hello() {
	echo "trap happen"
}
trap Hello 1 2 3 15 
while :
do
	:
done


#不希望DoImportantStuff被其他signals中斷,所以先忽略再恢復
#trap '' 1 2 3 15
#DoImportantStuff
#trap 1 2 3 15

